Methods for synchronizing access of parallel (concurrent) processes/applications to shared resources (including files, memory sections, etc.) of a computing system are presently known. When synchronization is provided, exclusive access is granted to a single process only and a resource itself is locked for writing and/or reading by other processes. Locking can be performed by different methods, however, situations are possible when a resource is locked by multiple processes at the same time and none of the processes can either unlock or perform necessary operations on the shared resource.
This situation is commonly referred to as “deadlock”, and various mechanisms are used to detect and then eliminate deadlocks.
The known method for avoiding deadlocks when performing storage updates in a multi-processor environment having a local cache for each processor, wherein each processor is able to operate in a fast, slow, or enhanced slow mode, comprises:
receiving an instruction that includes accessing a data store;
switching the processor to the fast mode where multiple instructions are executed in parallel and a target cache entry associated with the data store is acquired from the local cache with an exclusive ownership status prior to execution of the instruction;
initializing execution of the instruction in the fast mode;
in response to detecting a possible deadlock during execution in the fast mode:                interrupting execution of the instruction in the fast mode;        switching the processor to the slow mode where a single instruction is executed at a time and the target cache entry is acquired from the local cache with the exclusive ownership status prior to execution of the instruction;        initializing execution of the instruction in the slow mode;        
in response to detecting a possible deadlock during execution in the slow mode:                interrupting execution of the instruction in the slow mode;        switching the processor to the enhanced slow mode where a single instruction is executed at a time and the target cache entry is acquired from the local cache with a read only status prior to execution of the instruction and with the exclusive ownership status upon completion of execution of the instruction; and        initializing execution of the instruction in the enhanced slow mode (See U.S. Pat. No. 7,953,932).        
Upon completion of execution of the instruction in the enhanced slow mode (or in the slow mode), the processor can be reset to the fast mode.
A possible deadlock is regarded as detected when a predetermined threshold number of exclusive rejects is exceeded without any indicia of completion of execution of the instruction.
This method has disadvantages, such as, in particular, the need to switch the processor to the slow and enhanced slow mode, which deteriorates performance of the computing system. Furthermore, detection of a deadlock has a probabilistic nature and depends on the predetermined threshold number of exclusive rejects.
Another known method for synchronizing access to shared resources between parallel processes using a lock file mechanism comprises:
associating a shared resource with a lock file;
creating a lock file when a process (application) attempts to access the shared resource;
if such a lock file already exists, the operation is ended with an error;
if such a lock file does not exist, the lock file is created;
writing, to the lock file just created and opened, data of the process that has created the lock file (a process ID (PID), etc.);
causing the process to perform operations on the shared resource;
unlocking the shared resource (file) by removing the lock file.
The method described above is considered to be known (See Michael K. Johnson, Erik W. Troan. Linux Application Development, 2nd ed., Addison-Wesley Professional; 2nd edition (Nov. 27, 2004), Section 13.3: File Locking).
However, said known method has a drawback as well. In particular, if a process possessing a lock has completed incorrectly and has not removed the lock file, then none of the processes can access the shared resource, and a deadlock arises. Therefore, reliability of this known method is not high.